<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
      <div class="x_title">
        <h2>更改广告 <i class="fa fa-user"></i><small>${devUserSession.devName}</small></h2>
             <div class="clearfix"></div>
      </div>
      <div class="x_content" id="fromItem">

      </div>
    </div>
  </div>
</div>
<%@include file="common/footer.jsp"%>
<script language="JavaScript" type="text/javascript">
    // 获取当前URL的查询参数
    const urlParams = new URLSearchParams(window.location.search);
    const id = urlParams.get('id'); // 获取id参数
    //jquery的加载函数
    $(function () {
        $.post("/content1/getById",{id:id},function (response) {

            var item = `<div class="clearfix"></div>
            <form class="form-horizontal form-label-left" action="${pageContext.request.contextPath }/content1/updateContent" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="`+response.id+`">
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">广告类别<span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select name="categoryId" id="category" class="form-control"   required="required">
                <option value="`+response.categoryId+`">重新选择</option>
              </select>
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="softwareName" class="form-control col-md-7 col-xs-12"
               data-validate-length-range="20" data-validate-words="1" name="title"  required="required"
               placeholder="标题" type="text" value="`+response.title+`">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">url <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="url" class="form-control col-md-7 col-xs-12"
              	data-validate-length-range="20" data-validate-words="1" name="url"   required="required"
              	placeholder="请输入url" type="text" value="`+response.url+`">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">状态<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="radio" value="1" name="status" `+(response.status == 1 ? 'checked' : '')+` >可见
              <input type="radio" value="0" name="status" `+(response.status == 0 ? 'checked' : '')+`>不可见
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">顺序<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="APKName" class="form-control col-md-7 col-xs-12"
                     data-validate-length-range="20" data-validate-words="1" name="sortOrder"   required="required"
                     placeholder="请输入顺序" type="text" value="`+response.sortOrder+`">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">广告图片<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            <input type="file" class="form-control col-md-7 col-xs-12" name="contentpic"  id="a_logoPicPath"/>
            ${fileUploadError }
            </div>
            <a target='_blank' href="`+response.pic+`">查看当前图片</a>
          </div>
          <div class="ln_solid"></div>
          <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
              <button id="send" type="submit" class="btn btn-success">保存</button>
              <button type="button" class="btn btn-primary" id="back" onclick="btn_back()">返回</button>
              <br/><br/>
            </div>
          </div>
        </form>`;
            $("#fromItem").append(item)
        },"json")
            $.post("/content/getTbContentAll",null,function (data) {
                for (var i =0;i<data.length;i++){
                    var options = "<option value="+data[i].id+">"+data[i].name+"</option>"
                    $("#category").append(options)
                }
            },"json")
    })




  function btn_back() {
      window.location.href = "${pageContext.request.contextPath }/jsp/developer/controlContent.jsp";
  }
</script>